using System.ComponentModel.DataAnnotations;
using System.Data.Entity.ModelConfiguration;

namespace G15_Agent.Models.Mapping
{
    public class DanhSachNCCMap : EntityTypeConfiguration<DanhSachNCC>
    {
        public DanhSachNCCMap()
        {
            // Primary Key
            this.HasKey(t => t.MaNCC);

            // Properties
            this.Property(t => t.MaNCC)
                .IsRequired()
                .HasMaxLength(15);

            this.Property(t => t.TenNCC)
                .HasMaxLength(50);

            this.Property(t => t.DiaChiWS)
                .HasMaxLength(100);

            this.Property(t => t.Username)
                .HasMaxLength(50);

            this.Property(t => t.Pass)
                .HasMaxLength(50);

            // Table & Column Mappings
            this.ToTable("DanhSachNCC");
            this.Property(t => t.MaNCC).HasColumnName("MaNCC");
            this.Property(t => t.TenNCC).HasColumnName("TenNCC");
            this.Property(t => t.TLGiaNCC).HasColumnName("TLGiaNCC");
            this.Property(t => t.TLGiaKH).HasColumnName("TLGiaKH");
            this.Property(t => t.DiaChiWS).HasColumnName("DiaChiWS");
            this.Property(t => t.Username).HasColumnName("Username");
            this.Property(t => t.Pass).HasColumnName("Pass");
            this.Property(t => t.LoaiNCC).HasColumnName("LoaiNCC");
            this.Property(t => t.TrangThai).HasColumnName("TrangThai");

            // Relationships
            this.HasOptional(t => t.LoaiNCC1)
                .WithMany(t => t.DanhSachNCCs)
                .HasForeignKey(d => d.LoaiNCC);

        }
    }
}
